<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DeepSeek Chat</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        #messageInput { width: 300px; padding: 5px; }
        #response { width: 400px; height: 200px; border: 1px solid #ccc; padding: 10px; }
    </style>
</head>
<body>
    <h1>DeepSeek Chat</h1>
    <input type="text" id="messageInput" placeholder="Enter your message">
    <button onclick="sendMessage()">Send</button>
    <div id="response"></div>

    <script>
        let eventSource;

        function sendMessage() {
            const messageInput = document.getElementById('messageInput');
            const responseDiv = document.getElementById('response');
            const message = messageInput.value;

            if (message.trim() === '') return;

            responseDiv.innerHTML = '';

            // 创建一个新的EventSource
            eventSource = new EventSource(`http://localhost:8075/chat?message=${encodeURIComponent(message)}`);

            eventSource.onmessage = function (event) {
                console.log(event.data)
                responseDiv.innerHTML += event.data;
            };

            eventSource.onerror = function (error) {
                console.error('EventSource error:', error);
                eventSource.close();
            };
        }
    </script>
</body>
</html>